<template>
    <div id="one">
        {{ myMsg }}
        <el-button @click="tellFather">我变成了唐运远</el-button>
    </div>
</template>

<script>
    export default {
        name: "",
        props: ['msg'],
        data() {
            return {
                myMsg: this.msg
            }
        },
        watch: {
            msg(val) {
                this.myMsg = val;
            }
        },
        methods: {
            tellFather() {
                // this.$emit('zhaosn', '我变成了唐运远');
                // 修改仓库内的信息
                this.$store.commit('setUser', {
                    msg: '我变成了唐运远',
                    img: 'https://p9.itc.cn/images01/20210508/69dc68ff04b74c6487bbfc1689640a60.jpeg'
                });
            }
        }

    }
</script>

<style lang="scss">
  #one {
    border: solid 1px red;
    margin: 10px 0;
  }

</style>